package com.blackitheima3.LambdaDemo;

import java.util.Random;

//抽象方法 无参有返回值
public class TestRandom {
    public static void main(String[] args) {
        //匿名内部类
        getRandom(new GoRAndom() {
            @Override
            public int getR() {
                Random r=new Random();
                return r.nextInt(10)+1;
            }
        });
        //Lambda表达式
        getRandom(()->{
            Random r=new Random();
            return r.nextInt(10)+1;
        });


    }
    public static void getRandom(GoRAndom goRAndom){
        int result=goRAndom.getR();
        System.out.println(result);
    }
}
interface GoRAndom{
    public abstract int getR();
}
